<head>
<style type="text/css">@import url(library/dynarch_calendar.css);</style>
<script type="text/javascript" src="library/dialog.js"></script>
<script type="text/javascript" src="library/textformat.js"></script>
<script type="text/javascript" src="library/dynarch_calendar.js"></script>
{php} include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); {/php}
<script type="text/javascript" src="library/dynarch_calendar_setup.js"></script>
<script language="JavaScript">
 var mypcc = '{php} echo $GLOBALS['phone_country_code'] {/php}';

 // Process click on Delete link.
 function deleteme(docid) {literal}{{/literal}
  dlgopen('interface/patient_file/deleter.php?document=' + docid, '_blank', 500, 450);
  return false;
 {literal}}{/literal}

 // Called by the deleter.php window on a successful delete.
 function imdeleted() {literal}{{/literal}
  top.restoreSession();
  window.location.href='{$REFRESH_ACTION}';
 {literal}}{/literal}

 // Called to show patient notes related to this document in the "other" frame.
 function showpnotes(docid) {literal}{{/literal}
{php} if ($GLOBALS['concurrent_layout']) { {/php}
  var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
  parent.left_nav.forceDual();
  parent.left_nav.setRadio(othername, 'pno');
  parent.left_nav.loadFrame('pno1', othername, 'patient_file/summary/pnotes.php?docid=' + docid);
{php} } {/php}
  return false;
 {literal}}{/literal}

 function submitNonEmpty( e ) {literal}{{/literal}
	if ( e.elements['passphrase'].value.length == 0 ) {literal}{{/literal}
		alert( "{xl t='You must enter a pass phrase to encrypt the document'}" );
	{literal}}{/literal} else {literal}{{/literal}
		e.submit();
	{literal}}{/literal}
 {literal}}{/literal}

</script>

</head>

<table valign="top" width="100%">
    <tr>
        <td>
            <a class="css_button" href="{$web_path}" onclick="top.restoreSession()"><span>{xl t='Download'}</span></a>
            <a class="css_button" href='' onclick='return showpnotes({$file->get_id()})'><span>{xl t='Show Notes'}</span></a>
            {$delete_string}
        </td>
    </tr>
    <tr>
		<td valign="top">
			{if !$hide_encryption}
			<div class="text">
                <form method="post" name="document_encrypt" action="{$web_path}" onsubmit="return top.restoreSession()">
                <div>
                    <div style="float:left">
                        <b>{xl t='Encryption'}</b>&nbsp; 
                    </div>
                    <div style="float:none">
                        <a href="javascript:;" onclick="submitNonEmpty( document.forms['document_encrypt'] );">(<span>{xl t='download encrypted file'})</span></a>
                    </div> 
                </div>
                <div>
                    {xl t='Pass Phrase'}:
                    <input title="{xl t='Supports TripleDES encryption/decryption only.'} {xl t='Leaving the pass phrase blank will not encrypt the document'}" type='text' size='20' name='passphrase' id='passphrase' value=''/>
                    <input type="hidden" name="encrypted" value="true"></input>
              	</div>
                </form>
            </div>
            <br/>
            {/if}
			<div class="text">
                <form method="post" name="document_validate" action="{$VALIDATE_ACTION}" onsubmit="return top.restoreSession()">
                <div>
                    <div style="float:left">
                        <b>{xl t='Sha-1 Hash'}:</b>&nbsp;
                        <i>{$file->get_hash()}</i>&nbsp;
                    </div>
                    <div style="float:none">
                        <a href="javascript:;" onclick="document.forms['document_validate'].submit();">(<span>{xl t='validate'})</span></a>
                    </div>
                </div>
                </form>
            </div>
            <br/>
            <div class="text">
                <form method="post" name="document_update" action="{$UPDATE_ACTION}" onsubmit="return top.restoreSession()">
                <div>
                    <div style="float:left">
                        <b>{xl t='Update'}</b>&nbsp;
                    </div>
                    <div style="float:none">
                        <a href="javascript:;" onclick="document.forms['document_update'].submit();">(<span>{xl t='submit'})</span></a>
                    </div>
                </div>
                <div>
                    {xl t='Rename'}:
                    <input type='text' size='20' name='docname' id='docname' value='{$file->get_url_web()}'/>
              	</div>
                <div>
                    {xl t='Date'}:
                    <input type='text' size='10' name='docdate' id='docdate'
                     value='{$DOCDATE}' title='{xl t='yyyy-mm-dd document date'}'
                     onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
                    <img src='interface/pic/show_calendar.gif' id='img_docdate' align='absbottom'
                     width='24' height='22' border='0' alt='[?]' style='cursor:pointer'
                     title='{xl t='Click here to choose a date'}' />
                    <select name="issue_id">{$ISSUES_LIST}</select>
                </div>
                </form>
            </div>

            <br/>

            <div class="text">
                <form method="post" name="document_move" action="{$MOVE_ACTION}" onsubmit="return top.restoreSession()">
                <div>
                    <div style="float:left">
                        <b>{xl t='Move'}</b>&nbsp;
                    </div>
                    <div style="float:none">
                        <a href="javascript:;" onclick="document.forms['document_move'].submit();">(<span>{xl t='submit'})</span></a>
                    </div>
                </div>

                <div>
                        <select name="new_category_id">{$tree_html_listbox}</select>&nbsp;
                        {xl t='Move to Patient'} # <input type="text" name="new_patient_id" size="4" />
                        <a href="javascript:{literal}{}{/literal}"
                         onclick="top.restoreSession();var URL='controller.php?patient_finder&find&form_id={"document_move['new_patient_id']"|escape:"url"}&form_name={"document_move['new_patient_name']"|escape:"url"}'; window.open(URL, 'document_move', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=450,height=400,left=425,top=250');">
                        <img src="images/stock_search-16.png" border="0" /></a>
                        <input type="hidden" name="new_patient_name" value="" />
                </div>
                </form>
            </div>

            <br/>

            <form name="notes" method="post" action="{$NOTE_ACTION}" onsubmit="return top.restoreSession()">
            <div class="text">
                <div>
                    <div style="float:left">
                        <b>{xl t='Notes'}</b>&nbsp;
                    </div>
                    <div style="float:none">
                        <a href="javascript:;" onclick="document.forms['notes'].submit();">(<span>{xl t='add'}</span>)</a>
                    </div>
                <div>
                    <textarea cols="53" rows="8" wrap="virtual" name="note" style="width:100%"></textarea><br>
                    <input type="hidden" name="process" value="{$PROCESS}" />
                    <input type="hidden" name="foreign_id" value="{$file->get_id()}" />

                    {if $notes}
                    <div style="margin-top:7px">
                        {foreach name=note_loop from=$notes item=note}
                        <div>
                        {xl t='Note'} #{$note->get_id()}
                        {xl t='Date:'} {$note->get_date()}
                        {$note->get_note()}
                        </div>
                        {/foreach}
                        {/if}
                    </div>
                </div>
            </div>
            </form>

		</td>
	</tr>
	<tr>
		<td>
            <div class="text"><b>{xl t='Content'}</b></div>
            {if $file->get_mimetype() eq "image/tiff"}
			<embed frameborder="0" type="{$file->get_mimetype()}" src="{$web_path}as_file=false"></embed>
			{elseif $file->get_mimetype() eq "image/png" or
			 $file->get_mimetype() eq "image/jpg" or
			 $file->get_mimetype() eq "image/jpeg" or
			 $file->get_mimetype() eq "image/gif" or
			 $file->get_mimetype() eq "application/pdf" }
			<iframe frameborder="0" type="{$file->get_mimetype()}" src="{$web_path}as_file=false"></iframe>
			{elseif $file->get_ccr_type($file->get_id()) ne "CCR" and
       $file->get_ccr_type($file->get_id()) ne "CCD"}
			<iframe frameborder="0" type="{$file->get_mimetype()}" src="{$web_path}as_file=true"></iframe>
			{/if}
		</td>
	</tr>
</table>
<script language='JavaScript'>
 Calendar.setup({literal}{{/literal}inputField:"docdate", ifFormat:"%Y-%m-%d", button:"img_docdate"{literal}}{/literal});
</script>
